﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using mock_ehr_lib.Model;

namespace mock_ehr_lib.View.MainTabs
{
    public partial class Alerts : UserControl
    {
        public Alerts()
        {
            InitializeComponent();
            if (DesignMode) return;
            Load += alertsLoad;
            MockEHRApplication.Instance.OnPatientChanged += onPatientChanged;
        }

        void alertsLoad(object sender, EventArgs e)
        {
            var currentPatient = MockEHRApplication.Instance.CurrentPatient;
            if (currentPatient == null) return;
            dgvAlerts.DataSource = currentPatient.Summary.Alerts;
        }

        void onPatientChanged(Patient newPatient)
        {
            alertsLoad(this, null);
        }
    }
}
